using System;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace System.IPod.Music
{
	public class PlaylistItem : Node
	{
		Mhip m_mhip;

		//protected override int Size
		//{
		//    get { return m_mhip.HeaderLength; }
		//}

		protected override void ReadImpl(BinaryReader reader)
		{
			m_mhip = new Mhip();
			m_mhip.Read(reader);

			for (int k = 0; k < m_mhip.DataObjectChildCount; k++)
			{
				DataObject dataObj = new DataObject();
				AddChild(dataObj);
				dataObj.Read(reader);

				if (dataObj.Type == 1)
				{
					DataString dataString = new DataString();
					dataObj.AddChild(dataString);
					dataString.Read(reader);
				}
				else
				{
					DataBlob dataBlob = new DataBlob();
					dataObj.AddChild(dataBlob);
					dataBlob.Read(reader);
				}
			}
		}

		protected override void WriteImpl(BinaryWriter writer)
		{
			m_mhip.Write(writer);
		}

		protected override void SetSize(int size)
		{
			m_mhip.TotalLength = size;
		}
	}
}
